package com.pj.wisdomlogistics.mvp.presenter;


import com.pj.wisdomlogistics.mvp.contract.RegistContract;
import com.pj.wisdomlogistics.mvp.frame.ActivityPresenter;
import com.pj.wisdomlogistics.mvp.model.RegistModel;
import com.pj.wisdomlogistics.rx.FilterSubscriber;


public class RegistPresenter extends ActivityPresenter<RegistModel, RegistContract.View> implements RegistContract.Presenter {
    public static final String TAG = "RegistPresenter";

    @Override
    public void regist(String loginName, String password, String name, String mobile) {
        addSubscription(getModel().regist(loginName, password, name, mobile), new FilterSubscriber() {
            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onRegistError(errorMsg);
            }

            @Override
            public void onNext(Object mO) {
                getView().onRegistSuccess();
            }
        });
    }

    @Override
    public void userMsg(String mobile) {
        addSubscription(getModel().userMsg(mobile), new FilterSubscriber<String>() {
            @Override
            public void onNext(String mS) {
                getView().onCodeSuccess(mS);
            }

            @Override
            public void onError(int errorCode, String errorMsg) {
                getView().onError(errorMsg);
            }

        });
    }
}
